﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace AppHelper
{
    /// <summary>
    /// 日志帮助类
    /// </summary>
    public class LogHelper
    {
        public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
        public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");

        [Obsolete]
        static LogHelper() { 
            log4net.Config.DOMConfigurator.Configure(new FileInfo("log4net.config"));
        }
        /// <summary>
        /// 记录信息
        /// </summary>
        /// <param name="info"></param>
        public static void Info(string info)
        {
            if (loginfo.IsInfoEnabled)
            {
                loginfo.Info(info);
            }
        }
        /// <summary>
        /// 记录信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="ex"></param>
        public static void Info(string info, Exception ex)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Info(info, ex);
            }
        }
        /// <summary>
        /// 记录错误
        /// </summary>
        /// <param name="info"></param>
        public static void Error(string info)
        {
            if (loginfo.IsInfoEnabled)
            {
                loginfo.Error(info);
            }
        }
        /// <summary>
        /// 记录错误
        /// </summary>
        /// <param name="info"></param>
        /// <param name="ex"></param>
        public static void Error(string info, Exception ex)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Error(info, ex);
            }
        }
    }
}
